﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "IElement.h"
#include "ElementCreationOptions.h"
#include "UniIdentity.h"
#include "IElementParameters.h"
#include "IGraphicsElementShape.h"
#include "GcmpModel.h"

namespace gcmp
{
    /// \brief 用于创建IncompleteElement的输入数据
    /// 
    /// 目前包括所属文档、指定ElementId、参数组件、图形表达组件
    class GCMP_MODEL_EXPORT IncompleteElementInput : public IObject
    {
        DEFINE_CAST_DERIVED(gcmp::IncompleteElementInput, gcmp::IObject);
    public:
        /// \brief IncompleteElement输入数据的构造函数
        /// 
        /// \param pDocument 所属文档
        /// \param elementId 指定的Element
        /// \param cateGoryUniIdentity 类别的UniIdentity
        /// \param opElementParameters 参数组件
        /// \param opElementModelShape 模型图形表达组件
        IncompleteElementInput(
            IDocument* pDocument,
            const ElementId& elementId,
            UniIdentity cateGoryUniIdentity,
            OwnerPtr<IElementParameters> opElementParameters,
            OwnerPtr<IGraphicsElementShape> opGraphicsElementShape)
            :m_pDoc(pDocument),
            m_visibility(true),
            m_elementId(elementId),
            m_categoryUid(cateGoryUniIdentity),
            m_opElementParameters(TransferOwnership(opElementParameters)),
            m_opGraphicsElementShape(TransferOwnership(opGraphicsElementShape))
        {
        };
    public:
        /// \brief 获取所属文档
        /// \return 所属文档
        IDocument* GetDocument() const { return m_pDoc; }

        /// \brief 设置构件可见性
        /// 
        /// \param visibility 设置的可见性
        /// \return void
        void SetVisibility(bool visibility) { m_visibility = visibility;  }

        /// \brief 获取构件可见性
        /// \return 获取的构件可见性
        bool GetVisibility() const { return m_visibility; }

        /// \brief 获取指定的ElementId
        /// \return 指定的ElementId
        ElementId GetElementId() const { return m_elementId; }

        /// \brief 获取类别的UniIdentity
        /// \return 类别的UniIdentity
        UniIdentity GetCategoryUniIdentity() const { return m_categoryUid; }

        /// \brief 获取参数组件
        /// \return 参数组件
        OwnerPtr<IElementParameters> GetElementParameters() { return TransferOwnership(m_opElementParameters); }

        /// \brief 获取图形表达组件
        /// \return 图形表达
        OwnerPtr<IGraphicsElementShape> GetGraphicsElementShape() { return TransferOwnership(m_opGraphicsElementShape); }

    private:
        bool m_visibility;                                                  //构件可见性
        IDocument* m_pDoc;                                           //所属文档
        ElementId m_elementId;                                       //指定的ElementId
        UniIdentity m_categoryUid;                                   //类别的UniIdentity
        OwnerPtr<IElementParameters> m_opElementParameters;          //参数组件
        OwnerPtr<IGraphicsElementShape> m_opGraphicsElementShape;    //图形表达
    };

    /// \brief 用于挂载不能识别的Element的图形和参数数据
    ///
    ///
    class GCMP_MODEL_EXPORT IIncompleteElement : public IElement
    {
        DEFINE_CAST_DERIVED(gcmp::IIncompleteElement, gcmp::IElement);

        /// \brief 创建指定ElementId的IncompleteElement
        /// 
        /// \param pInput 用于创建IncompleteElement的输入数据
        /// \return 创建后的IncompleteElement
        static IIncompleteElement* CreateFromInput(IncompleteElementInput* pInput);

    public:
        /// \brief 获取Implementation Uid
        ///
        /// \return UniIdentity 返回ImplementationUid
        static UniIdentity GetImplementationUid();
    };
}
